import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ClientVO, ClientForm, ClientQuery } from '@/api/germbank/apply/partner/types';

/**
 * 查询医疗团队管理列表
 * @param query
 * @returns {*}
 */

export const listDoctor = (query?: ClientQuery): AxiosPromise<ClientVO[]> => {
  return request({
    url: '/germbank/doctor/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询医疗团队管理详细
 * @param id
 */
export const getDoctor = (id: string | number): AxiosPromise<ClientVO> => {
  return request({
    url: '/germbank/client/' + id,
    method: 'get'
  });
};

/**
 * 新增医疗团队管理
 * @param data
 */
export const addDoctor = (data: ClientForm) => {
  return request({
    url: '/germbank/client',
    method: 'post',
    data: data
  });
};

/**
 * 修改医疗团队管理
 * @param data
 */
export const updateDoctor = (data: ClientForm) => {
  return request({
    url: '/germbank/client',
    method: 'put',
    data: data
  });
};

/**
 * 删除医疗团队管理
 * @param id
 */
export const delDoctor = (id: string | number | Array<string | number>) => {
  return request({
    url: '/germbank/client/' + id,
    method: 'delete'
  });
};

/**
 * 状态修改
 * @param doctorId 商业伙伴id
 * @param status 状态
 */
export function changeStatus(clientId: string, status: string) {
  const data = {
    clientId,
    status
  };
  return request({
    url: '/germbank/client/changeStatus',
    method: 'put',
    data: data
  });
}

// 刷新医疗团队缓存
export function refreshCache() {
  return request({
    url: '/system/dict/type/refreshCache',
    method: 'delete'
  });
}
